package net.kleinhenz.questor.model;

import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.core.Commit;

public class Media
{
	@Attribute(required=false, name="condition")
	private String conditionText = null;
	
	@Attribute(required=false, name="conditiontype")
	private Executable.Type conditionType = null;
	
	@Attribute
	private String src = null;

	@Attribute
	private String type = null;

	@Element(required=false)
	private Condition condition = null;
	
	public String getSource()
	{
		return src;
	}
	
	public void setSource(String source)
	{
		this.src = source;
	}
	
	public String getType()
	{
		return type;
	}
	
	public void setType(String type)
	{
		this.type = type;
	}	
	
	public void setConditionText(String conditionText) {
		this.conditionText = conditionText;
	}

	public String getConditionText() {
		return conditionText;
	}

	public void setConditionTypeText(Executable.Type conditionType) {
		this.conditionType = conditionType;
	}

	public Executable.Type getConditionType() {
		return conditionType;
	}
	
	public void setCondition(Condition condition) {
		this.condition = condition;
	}

	public Condition getCondition() {
		return condition;
	}

	@Commit
	public void createCondition() {
		if (getConditionType()!=null && getConditionText()!=null)
			setCondition(ConditionFactory.createCondition(getConditionType(), getConditionText()));
	}
}
